package etc.com.sql;

import java.sql.ResultSet;
import java.sql.Statement;

import etc.com.market.MarketSystem;

import Controls.ProdTypeVO;
import android.content.Context;

public class SpecifyProdAdaptersql {

	// Product Table
	// private static final String FRAME_TABLE = "Products";
	// private static final String FAVORITE_TABLE = "Favorite";
	public static final String FNAME_PRDID = "PRDID";
	public static final String FNAME_PRDNM = "PRDNM";
	public static final String FNAME_SHRTDESC = "SHRTDESC";
	public static final String FNAME_PRDTP = "PRDTP";
	public static final String FNAME_IMAGE = "IMAGE";
	public static final String FNAME_UPPRDID = "UPPRDID";
	public static final String FNAME_HasDetailCount = "hasDetailCount";

	private MarketSystem app;
	private Context m_context;

	public SpecifyProdAdaptersql(Context ctx) {
		m_context = ctx;
		app = (MarketSystem) ctx.getApplicationContext();
	}

	public String[] GetProductTypeList(String PRTP) {
		String re = "";
		String filter = FNAME_PRDTP + " = '" + PRTP + "'" + FNAME_UPPRDID
				+ "is null";
		String sql = "SELECT * FROM Products where " + filter;
		ResultSet rst;

		// List<String> lst = Arrays.asList(re);
		String splitStr = "@@";

		try {
			Statement stmt = ConnectionManager.GetStatement();
			rst = stmt.executeQuery(sql);
			while (rst.next()) {
				re += splitStr + rst.getString(FNAME_PRDNM);
			}

		} catch (java.sql.SQLException e) {

			e.printStackTrace();
		}

		return re.split(splitStr);
	}

	private ProdTypeVO GetProdTypeVO(ResultSet rst)
			throws java.sql.SQLException {
		ProdTypeVO vo = new ProdTypeVO();

		vo.setName(rst.getString(FNAME_PRDNM) != null ? rst.getString(
				FNAME_PRDNM).replace("\r\n", "\n") : "");

		return vo;
	}
}
